package com.handinfo.android.game.item;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

public class MailItem
{
	public static final byte 收件显示_全部 = 0;//收件箱
	public static final byte 收件显示_未读 = 1;
	
	public static final byte 状态_未读 = 1;
	public static final byte 状态_已读 = 2;
	//data logic
	public long m_id;//每个邮件的ID
	public String m_title;//邮件名
	public String m_content;//正文
	public String m_recvName;//收件人名字
	public String m_sendName;//发件人名字
	public String m_time;//显示时间
	public byte m_state;//状态码 0未读 1已读
	public Item m_item;//附件道具
	public long m_money;//附件金钱
	
	public boolean m_select;//是否被勾选
    
	public void clear(String recvName){
		m_id = 0;
		m_title = null;
		m_time = null;
		m_content = null;
		m_recvName = recvName;
		m_sendName = null;
		m_item = null;
		m_money = 0;
	}
	
	
	/**获取日期
	 * @param time 时间（0）时取系统默认
	 * @return YY-MM-DD
	 * */
	public static final String getData(Long time){
		if(time == 0){
			time = System.currentTimeMillis();
		}
		SimpleDateFormat  sDateFormat = new SimpleDateFormat("MM-dd");
		String data = sDateFormat.format(new java.util.Date(System.currentTimeMillis()));
		return data;
	}
	
	/**
	 * 格林威治时间转换为标准时间
	 * @param time
	 * @return
	 */
	public static final String getTime()
	{
		TimeZone tz = TimeZone.getDefault();
		Calendar ca = Calendar.getInstance(tz);

		//Calendar 的 getInstance 方法返回一个 Calendar 对象，其日历字段已由当前日期和时间初始化 
		String strYear = String.valueOf(ca.get(Calendar.YEAR)); //获取当前年时间并转为字符串型 
		strYear = strYear.substring(2, strYear.length());
		String strMonth = String.valueOf(ca.get(Calendar.MONTH) + 1); //获取当前月时间并转为字符串型 

		//ca.get(Calendar.MONTH)+1为什么加一是因为,0表示1月,1表示2月,依次类推 
		String strDate = String.valueOf(ca.get(Calendar.DATE)); //获取当前日时间并转为字符串型 
		String SysDate = null;
		if ((ca.get(Calendar.MONTH) + 1) <= 9 && ca.get(Calendar.DATE) <= 9) {
			SysDate = strYear + "0" + strMonth + "0" + strDate;
		}
		else if ((ca.get(Calendar.MONTH) + 1) > 9 && ca.get(Calendar.DATE) > 9) {
			SysDate = strYear + strMonth + strDate;
		}
		else if ((ca.get(Calendar.MONTH) + 1) <= 9 && ca.get(Calendar.DATE) > 9) {
			SysDate = strYear + "0" + strMonth + strDate;
		}
		else if ((ca.get(Calendar.MONTH) + 1) > 9 && ca.get(Calendar.DATE) <= 9) {
			SysDate = strYear + strMonth + "0" + strDate;
		}
		else {
			SysDate = "NONE";
		}
		return SysDate;
	}


}
